package com.dwjm.shop.Merchant;


import com.dwjm.shop.goods.Goods;
import com.dwjm.shop.utils.ConnectionDatabaseForMySQLUseJdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class MerchantDaoImpl implements MerchantDao {
    Connection connection = null;
    PreparedStatement pstmt = null;
    ResultSet rest = null;

    public MerchantDaoImpl() {
        connection = ConnectionDatabaseForMySQLUseJdbc.getConnection();
    }

    @Override
    public boolean login(String account, String password) {
        try{
            pstmt = connection.prepareStatement("select * from t_merchant where account=? and password=?");
            pstmt.setString(1, account);
            pstmt.setString(2, password);
            rest = pstmt.executeQuery();
            if(rest.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }


}
